package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.login.annotation.TingShuLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.vo.album.AlbumInfoVo;
import com.atguigu.tingshu.vo.category.CategoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;


	//Request URL: http://localhost:8500/api/album/category/getBaseCategoryList

	@Operation(summary = "查询全平台的分类")
	@GetMapping("/getBaseCategoryList")
	public Result getBaseCategoryList() {
		 List<CategoryVo> categoryVoList =baseCategoryService.getBaseCategoryList();
		return Result.ok(categoryVoList);
	}

	//Request URL: http://localhost:8500/api/album/category/findAttribute/1
	@Operation(summary = "根据一级分类Id查询标签信息(属性名和属性值)")
	@GetMapping("/findAttribute/{c1Id}")
	public Result findAttribute(@PathVariable("c1Id") Long c1Id) {
		//根据前端需要的字段封装实体类
		List<BaseAttribute> baseAttrs =baseCategoryService.findAttribute(c1Id);
		return Result.ok(baseAttrs);
	}


	//Request URL: http://localhost:8500/api/album/category/findTopBaseCategory3/1
	@Operation(summary = "根据一级分类Id获取7个置顶的3级分类")
	@GetMapping("/findTopBaseCategory3/{c1Id}")
	public Result findTopBaseCategory(@PathVariable("c1Id") Long c1Id) {
		//根据前端需要的字段封装实体类
		List<BaseCategory3> category3s =baseCategoryService.findTopCategory3ByC1Id(c1Id);
		return Result.ok(category3s);
	}

	//Request URL: http://localhost:8500/api/album/category/getBaseCategoryList/2
	@Operation(summary = "根据1级分类Id查询所有的孩子")
	@GetMapping("/getBaseCategoryList/{c1Id}")
	public Result getBaseCategoryList(@PathVariable("c1Id") Long c1Id) {
		//根据前端需要的字段封装实体类
		CategoryVo categoryVo =baseCategoryService.getBaseCategoryList(c1Id);
		return Result.ok(categoryVo);
	}



}



